package com.sumainfor.pc.market.controller.gmf;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.market.service.GmfWorkBenchService;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Eddy·Chen
 * @Email 835033913@qq.com
 * @Create 2019-05-20 10:56
 * 总经办工作台
 */
@RestController
@RequestMapping("/gmf/workbench")
public class WorkBenchController {

    @Autowired
    private GmfWorkBenchService service;

    /**
     * 获取全部的服务中心列表数据
     *
     * @return
     */
    @RequestMapping("/getAllCenter")
    public JsonResult getAllCenter() {
        return service.getAllCenter();
    }

    /**
     * 获取服务中心的统计
     *
     * @param miID
     * @return
     */
    @RequestMapping("/getCenterStatistics")
    public JsonResult getCenterStatistics(Integer miID) {
        return service.getCenterStatistics(miID);
    }

    /**
     * 查询全部分公司统计信息
     *
     * @param areaId
     * @param startTime
     * @param endTime
     * @return
     */
    @RequestMapping("/getCompanyStatistics")
    public JsonResult getCompanyStatistics(Integer areaId, String startTime, String endTime) {
        if (StringUtils.isBlank(startTime) || StringUtils.isBlank(endTime)) {
            //给默认值
            DateTime dtTarget = DateTime.now();
            DateTime.Property month = dtTarget.dayOfMonth();
            endTime = month.withMaximumValue().toString("yyyy-MM-dd");
            startTime = month.withMinimumValue().toString("yyyy-MM-dd");
        }
        return service.getCompanyStatistics(areaId, startTime, endTime);
    }

    /**
     * 查询年度收房统计
     *
     * @param year
     * @return
     */
    @RequestMapping("/getYearInHousing")
    public JsonResult getYearInHousing(String year) {
        return service.getYearInHousing(year);
    }

    /**
     * 查询年度租房统计
     *
     * @param year
     * @return
     */
    @RequestMapping("/getYearOutHousing")
    public JsonResult getYearOutHousing(String year) {
        return service.getYearOutHousing(year);
    }

    /**
     * 投诉类型统计
     *
     * @param year
     * @return
     */
    @RequestMapping("/getComplaint")
    public JsonResult getComplaint(String year) {
        return service.getComplaint(year);
    }
}
